# 9. 整数对最小和
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on('line', (input) => {
let arr1 = input.split(' ').map(Number).slice(1);
rl.on('line', (input) => {
let arr2 = input.split(' ').map(Number).slice(1);
rl.on('line', (input) => {
let k = parseInt(input);
const arr = [];
for(let val1 of arr1) {
for(let val2 of arr2) {
arr.push(val1 + val2);
}
}
arr.sort((a,b)=>a-b);
let ans = 0;
for(let i=0; i<k; i++) {
ans += arr[i];
}
console.log(ans);
});
});
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28